import request from '@utils/request'

// 获取宿舍列表
export function getRoomList (data) {
  return request({
    url: '/dormitory/getPageList',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 修改宿舍信息
export function updateRoom (data) {
  return request({
    url: '/dormitory/update',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 删除宿舍信息
export function deleteRoom (data) {
  return request({
    url: '/dormitory/delete',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 下载宿舍信息模板
export function downloadRoom (data) {
  return request({
    url: '/dormitory/downloadExcel',
    method: 'post',
    data: data,
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 导出宿舍信息
export function exportRoom (data) {
  return request({
    url: '/dormitory/export',
    method: 'post',
    data: data,
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 导入宿舍信息
export function uploadRoom (data) {
  return request({
    url: '/dormitory/upload',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}


// 根据楼宇查询宿舍信息
export function getDormByBuildId (query) {
  return request({
    url: '/dormitory/getDormByBuildId',
    method: 'post',
    params: query,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}